package com.itheima.io2;

import java.io.*;

/**
 * @author Anomaly
 * @date 2023/2/9 22:08
 */
public class BufferedStreamDemo {
    public static void main(String[] args) {
        try (
                InputStream is = new FileInputStream("file-io/src/test.txt");
                OutputStream os = new FileOutputStream("file-io/src/test_2.txt");
                InputStream bis = new BufferedInputStream(is);
                OutputStream bos = new BufferedOutputStream(os)

        ) {
            byte[] bytes = new byte[1024];
            int len;
            while ((len = bis.read(bytes)) != -1) {
                bos.write(bytes, 0, len);
            }
            System.out.println("拷贝完成。");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
